import type R from '@/types/conduit/R'
import type { CartItem } from '@/types/entity/ShoppingCart'
import type QueryConfirmRequireParams from '@/types/param/coupon'
import { OrderConfirmRequire } from '@/types/response/shop'
import type { CartItemVO } from '@/types/response/shopping-cart'
import request from '@/utils/request'

export const put = (cartItem: CartItem): Promise<R<CartItem>> =>
  request({
    url: `/shop/cart/put`,
    method: 'POST',
    data: cartItem
  })

export const list = (params: { shopId: number; seatNumber?: string; inviteCode?: string }): Promise<R<CartItemVO[]>> =>
  request({
    url: `/shop/cart/list`,
    params,
    method: 'GET'
  })
export const clear = (params: { shopId: number; seatNumber?: string; inviteCode?: string }): Promise<R<CartItem[]>> =>
  request({
    url: `/shop/cart/clear`,
    params: params,
    method: 'POST'
  })
export const queryOrderConfirmRequire = (
  queryConfirmRequireParams: QueryConfirmRequireParams
): Promise<R<OrderConfirmRequire>> =>
  request({
    url: `/shop/cart/order-confirm-require`,
    method: 'POST',
    data: queryConfirmRequireParams
  })
